package com.study.shop.config.web;

import com.study.shop.common.ShopException;
import com.study.shop.entity.common.R;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 全局异常处理类
 */
@RestControllerAdvice
public class GlobalExceptionHandler {

    /**
     * 处理全局异常
     *
     * @param e 异常
     * @return R
     */
    @ExceptionHandler(ShopException.class)
    public R handlerShopException(Exception e) {
        return R.error(e.getMessage());
    }
}
